﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System;
using System.Reflection;
using Fulcrum.DispatcherProxies;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.DispatcherProxies
{
    [TestClass]
    public class DispatcherProxyInstanceMemberInfoTests
    {
        public DispatcherProxyInstanceMemberInfoTests()
        {
            // nothing
        }

        [TestMethod]
        public void TestDispatcherProxyInstanceMemberInfoObsoleteAttributeNull()
        {
            var methodInfo = this.GetType().GetMethod("NotObsoleteMethod");
            var info = new TestInstanceMemberInfo(methodInfo);

            Assert.IsNull(info.ObsoleteAttribute);
        }

        [TestMethod]
        public void TestDispatcherProxyInstanceMemberInfoObsoleteAttributeNotNull()
        {
            var methodInfo = this.GetType().GetMethod("ObsoleteMethod");
            var info = new TestInstanceMemberInfo(methodInfo);

            Assert.IsNotNull(info.ObsoleteAttribute);
        }

        public void NotObsoleteMethod()
        {
            throw new NotImplementedException();
        }

        [Obsolete]
        public void ObsoleteMethod()
        {
            throw new NotImplementedException();
        }

        class TestInstanceMemberInfo : DispatcherProxyInstanceMemberInfo
        {
            public TestInstanceMemberInfo(MemberInfo member)
                : base(member, false)
            {
                // nothing
            }
        }

    }
}
